package wish;

import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import control.ServerIp;

public class WishDeleteServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
    public WishDeleteServlet() {
        super();
    }
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//request.setCharacterEncoding("euc-kr");
		request.setCharacterEncoding("utf-8");
		ServerIp ip = new ServerIp();
		Connection conn = null;
		Statement stmt = null;
		//ResultSet rs = null;
		PreparedStatement pstmt = null;
		
		int getGW_NO = Integer.parseInt(request.getParameter("gw_no"));
		System.out.print(getGW_NO);
		try{
			//Class.forName("oracle.jdbc.driver.OracleDriver");
			Class.forName(ip.getDriver());
			conn = DriverManager.getConnection(ip.getUrl(),ip.getId(),ip.getPw());
			stmt = conn.createStatement();
			
			pstmt = conn.prepareStatement("delete from goods_wish where gw_no=?");
			pstmt.setInt(1, getGW_NO);
			pstmt.executeUpdate();
			
			//String delsql = "delete from goods_wish where gw_no="+getGW_NO;
			//rs = stmt.executeQuery(delsql);
		}catch(Exception e){
			e.printStackTrace();
		}finally{
			try{
				//rs.close();
				stmt.close();
				conn.close();
				pstmt.close();
			}catch(Exception e){}
		}
		response.sendRedirect("/Dmyna/myshop/wish/wishList.jsp");
	}
}